package com.mycompany.project.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.dom.client.Style.Position;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;



/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */

//shuffle wrong figures
//
public class MemoryGUI implements EntryPoint {
	GameMechanics game = new GameMechanics();
	FlowPanel verticalPanel = new FlowPanel();
	HorizontalPanel horizontalPanel = new HorizontalPanel();
	Image image = new Image("images/pickme.png");
	private static final int PLAYERONE = 19;
	private static final int PLAYERTWO = 20;
	private static final int DELAY = 1000;
	private static final String PLAYERRESTART = "MEMORY";	
	Label lblPlayerName = new Label(PLAYERRESTART);
	FlexTable flexTable = new FlexTable();
	Button btnreset = new Button("Next Turn?");
	boolean secondPick = false;
	boolean gameRunning = true;
	boolean match = false;
	boolean gameOver=false;
	Timer t = new Timer(){
		@Override
		public void run() {
			btnreset.setVisible(true);				
		}};
			
	Image image1 = new Image((String) null);
	Image image2 = new Image((String) null);
	Image image3 = new Image((String) null);
	Image image4 = new Image((String) null);
	Image image5 = new Image((String) null);
	Image image6 = new Image((String) null);
	Image image7 = new Image((String) null);
	Image image8 = new Image((String) null);
	Image image9 = new Image((String) null);
	Image image10 = new Image((String) null);
	Image image11 = new Image((String) null);
	Image image12 = new Image((String) null);
	Image image13 = new Image((String) null);
	Image image14 = new Image((String) null);
	Image image15 = new Image((String) null);
	Image image16 = new Image((String) null);
	Image image17 = new Image((String) null);
	Image image18 = new Image((String) null);
	Image image19 = new Image((String) null);
	Image image20 = new Image((String) null);
	Image image21 = new Image((String) null);
	Image image22 = new Image((String) null);
	Image image23 = new Image((String) null);
	Image image24 = new Image((String) null);
	Image image25 = new Image((String) null);
	Image image26 = new Image((String) null);
	Image image27 = new Image((String) null);
	Image image28 = new Image((String) null);
	Image image29 = new Image((String) null);
	Image image30 = new Image((String) null);
	Image image31 = new Image((String) null);
	Image image32 = new Image((String) null);
	Image image33 = new Image((String) null);
	Image image34 = new Image((String) null);
	Image image35 = new Image((String) null);
	Image image36 = new Image((String) null);
	
	public void onModuleLoad() {
		RootPanel rootPanel = RootPanel.get("wrapper");
		rootPanel.getElement().getStyle().setPosition(Position.RELATIVE);
				
		rootPanel.add(verticalPanel, 22, 10);
		verticalPanel.setSize("900px", "1200px");
	
		verticalPanel.add(horizontalPanel);	
		horizontalPanel.setSpacing(10);
		horizontalPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
		horizontalPanel.add(image);
		image.setSize("98px", "94px");
		horizontalPanel.add(lblPlayerName);
		lblPlayerName.setStyleName("playerName");
		horizontalPanel.add(btnreset);
		btnreset.setVisible(false);
		btnreset.addClickHandler(new ClickHandler(){
			@Override
			public void onClick(ClickEvent event) {
				if(gameOver){
					game.resetGame();
					gameOver=false;
					
				}else{			
					game.swapPlayer();				
				}
				showName();
				secondPick=false;
				gameRunning=true;
				match=false;
				resetBoard();
				game.setPick(0);
				//btnreset.setVisible(true);
				t.schedule(DELAY);
				
			}});
		
		verticalPanel.add(flexTable);
		flexTable.setStyleName("memoryTable");
				image1.addClickHandler(new ClickHandler(){
					@Override
					public void onClick(ClickEvent event) {
						showPic(1);					
					}});
		
				flexTable.setWidget(1,0,image1);
				image1.setSize("80px", "80px");
				image1.setUrl("images/pickme.png");
				image2.addClickHandler(new ClickHandler() {
					public void onClick(ClickEvent event) {
						showPic(2);
					}
				});
				flexTable.setWidget(1,1,image2);
				image2.setSize("80px", "80px");
				image2.setUrl("images/pickme.png");
				flexTable.setWidget(1,2,image3);
				image3.addClickHandler(new ClickHandler() {
					public void onClick(ClickEvent event) {
						showPic(3);
					}
				});
				image3.setSize("80px", "80px");
				image3.setUrl("images/pickme.png");
				flexTable.setWidget(1,3,image4);
				image4.addClickHandler(new ClickHandler() {
					public void onClick(ClickEvent event) {
						showPic(4);
					}
				});
				image4.setSize("80px", "80px");
				image4.setUrl("images/pickme.png");
				flexTable.setWidget(1,4,image5);
				image5.addClickHandler(new ClickHandler() {
					public void onClick(ClickEvent event) {
						showPic(5);
					}
				});
				image5.setSize("80px", "80px");
				image5.setUrl("images/pickme.png");
				flexTable.setWidget(1,5,image6);
				image6.addClickHandler(new ClickHandler() {
					public void onClick(ClickEvent event) {
						showPic(6);
					}
				});
				image6.setSize("80px", "80px");
				image6.setUrl("images/pickme.png");
				
				flexTable.setWidget(2,0,image7);
				image7.addClickHandler(new ClickHandler() {
					public void onClick(ClickEvent event) {
						showPic(7);
					}
				});
				image7.setSize("80px", "80px");
				image7.setUrl("images/pickme.png");
				flexTable.setWidget(2,1,image8);
				image8.addClickHandler(new ClickHandler() {
					public void onClick(ClickEvent event) {
						showPic(8);
					}
				});
				image8.setSize("80px", "80px");
				image8.setUrl("images/pickme.png");
				flexTable.setWidget(2,2,image9);
				image9.addClickHandler(new ClickHandler() {
					public void onClick(ClickEvent event) {
						showPic(9);
					}
				});
				image9.setSize("80px", "80px");
				image9.setUrl("images/pickme.png");
				flexTable.setWidget(2,3,image10);
				image10.addClickHandler(new ClickHandler() {
					public void onClick(ClickEvent event) {
						showPic(10);
					}
				});
				image10.setSize("80px", "80px");
				image10.setUrl("images/pickme.png");
				flexTable.setWidget(2,4,image11);
				image11.addClickHandler(new ClickHandler() {
					public void onClick(ClickEvent event) {
						showPic(11);
					}
				});
				image11.setSize("80px", "80px");
				image11.setUrl("images/pickme.png");
				flexTable.setWidget(2,5,image12);
				image12.addClickHandler(new ClickHandler() {
					public void onClick(ClickEvent event) {
						showPic(12);
					}
				});
				image12.setSize("80px", "80px");
				image12.setUrl("images/pickme.png");
				
				flexTable.setWidget(3,0,image13);
				image13.addClickHandler(new ClickHandler() {
					public void onClick(ClickEvent event) {
						showPic(13);
					}
				});
				image13.setSize("80px", "80px");
				image13.setUrl("images/pickme.png");
				flexTable.setWidget(3,1,image14);
				image14.addClickHandler(new ClickHandler() {
					public void onClick(ClickEvent event) {
						showPic(14);
					}
				});
				image14.setSize("80px", "80px");
				image14.setUrl("images/pickme.png");
				flexTable.setWidget(3,2,image15);
				image15.addClickHandler(new ClickHandler() {
					public void onClick(ClickEvent event) {
						showPic(15);
					}
				});
				image15.setSize("80px", "80px");
				image15.setUrl("images/pickme.png");
				flexTable.setWidget(3,3,image16);
				image16.addClickHandler(new ClickHandler() {
					public void onClick(ClickEvent event) {
						showPic(16);
					}
				});
				image16.setSize("80px", "80px");
				image16.setUrl("images/pickme.png");
				flexTable.setWidget(3,4,image17);
				image17.addClickHandler(new ClickHandler() {
					public void onClick(ClickEvent event) {
						showPic(17);
					}
				});
				image17.setSize("80px", "80px");
				image17.setUrl("images/pickme.png");
				flexTable.setWidget(3,5,image18);
				image18.addClickHandler(new ClickHandler() {
					public void onClick(ClickEvent event) {
						showPic(18);
					}
				});
				image18.setSize("80px", "80px");
				image18.setUrl("images/pickme.png");
				
				flexTable.setWidget(4,0,image19);
				image19.addClickHandler(new ClickHandler() {
					public void onClick(ClickEvent event) {
						showPic(19);
					}
				});
				image19.setSize("80px", "80px");
				image19.setUrl("images/pickme.png");
				flexTable.setWidget(4,1,image20);
				image20.addClickHandler(new ClickHandler() {
					public void onClick(ClickEvent event) {
						showPic(20);
					}
				});
				image20.setSize("80px", "80px");
				image20.setUrl("images/pickme.png");
				flexTable.setWidget(4,2,image21);
				image21.addClickHandler(new ClickHandler() {
					public void onClick(ClickEvent event) {
						showPic(21);
					}
				});
				image21.setSize("80px", "80px");
				image21.setUrl("images/pickme.png");
				flexTable.setWidget(4,3,image22);
				image22.addClickHandler(new ClickHandler() {
					public void onClick(ClickEvent event) {
						showPic(22);
					}
				});
				image22.setSize("80px", "80px");
				image22.setUrl("images/pickme.png");
				flexTable.setWidget(4,4,image23);
				image23.addClickHandler(new ClickHandler() {
					public void onClick(ClickEvent event) {
						showPic(23);
					}
				});
				image23.setSize("80px", "80px");
				image23.setUrl("images/pickme.png");	
				flexTable.setWidget(4,5,image24);
				image24.addClickHandler(new ClickHandler() {
					public void onClick(ClickEvent event) {
						showPic(24);
					}
				});
				image24.setSize("80px", "80px");
				image24.setUrl("images/pickme.png");
				
				flexTable.setWidget(5,0,image25);
				image25.addClickHandler(new ClickHandler() {
					public void onClick(ClickEvent event) {
						showPic(25);
					}
				});
				image25.setSize("80px", "80px");
				image25.setUrl("images/pickme.png");
				flexTable.setWidget(5,1,image26);
				image26.addClickHandler(new ClickHandler() {
					public void onClick(ClickEvent event) {
						showPic(26);
					}
				});
				image26.setSize("80px", "80px");
				image26.setUrl("images/pickme.png");
				flexTable.setWidget(5,2,image27);
				image27.addClickHandler(new ClickHandler() {
					public void onClick(ClickEvent event) {
						showPic(27);
					}
				});
				image27.setSize("80px", "80px");
				image27.setUrl("images/pickme.png");
				flexTable.setWidget(5,3,image28);
				image28.addClickHandler(new ClickHandler() {
					public void onClick(ClickEvent event) {
						showPic(28);
					}
				});
				image28.setSize("80px", "80px");
				image28.setUrl("images/pickme.png");
				flexTable.setWidget(5,4,image29);
				image29.addClickHandler(new ClickHandler() {
					public void onClick(ClickEvent event) {
						showPic(29);
					}
				});
				image29.setSize("80px", "80px");
				image29.setUrl("images/pickme.png");
				flexTable.setWidget(5,5,image30);
				image30.addClickHandler(new ClickHandler() {
					public void onClick(ClickEvent event) {
						showPic(30);
					}
				});
				image30.setSize("80px", "80px");
				image30.setUrl("images/pickme.png");
				
				flexTable.setWidget(6,0,image31);
				image31.addClickHandler(new ClickHandler() {
					public void onClick(ClickEvent event) {
						showPic(31);
					}
				});
				image31.setSize("80px", "80px");
				image31.setUrl("images/pickme.png");
				flexTable.setWidget(6,1,image32);
				image32.addClickHandler(new ClickHandler() {
					public void onClick(ClickEvent event) {
						showPic(32);
					}
				});
				image32.setSize("80px", "80px");
				image32.setUrl("images/pickme.png");
				flexTable.setWidget(6,2,image33);
				image33.addClickHandler(new ClickHandler() {
					public void onClick(ClickEvent event) {
						showPic(33);
					}
				});
				image33.setSize("80px", "80px");
				image33.setUrl("images/pickme.png");
				flexTable.setWidget(6,3,image34);
				image34.addClickHandler(new ClickHandler() {
					public void onClick(ClickEvent event) {
						showPic(34);
					}
				});
				image34.setSize("80px", "80px");
				image34.setUrl("images/pickme.png");
				flexTable.setWidget(6,4,image35);
				image35.addClickHandler(new ClickHandler() {
					public void onClick(ClickEvent event) {
						showPic(35);
					}
				});
				image35.setSize("80px", "80px");
				image35.setUrl("images/pickme.png");
				flexTable.setWidget(6,5,image36);
				image36.addClickHandler(new ClickHandler() {
					public void onClick(ClickEvent event) {
						showPic(36);
					}
				});
				image36.setSize("80px", "80px");
				image36.setUrl("images/pickme.png");
				resetGame();
	}
	
	private void resetGame(){
		game.resetGame();
		showName();
	}
	
	private void showPic(int i){
		if(gameRunning && game.getData(i)!= PLAYERONE && game.getData(i) != PLAYERTWO && i!=game.getPick()){
		//show picture
		displayPic(i);
		//check for match
		if(game.getPick()==0){
			game.setPick(i);
			secondPick=false;
		}else{
			match = checkForMatch(i);
			secondPick=true;
		}
		if (match){
			game.incPlayer(game.getPlayer());
			game.setData(game.getPick(), game.getPlayer());
			game.setData(i, game.getPlayer());
			if(game.getPlayer()==19){
				lblPlayerName.setText("Croc has a match!!");
			} else{
				lblPlayerName.setText("Tiger has a match!!");
			}
			//change display			
		}
		if(checkForEndOfGame()){
			endOfGame();
		}else{
			if(secondPick){
				gameRunning = false;
				//btnreset.setVisible(true);
				t.schedule(DELAY);		
				}
			}
		}
	}
	
	
	
	private boolean checkForEndOfGame(){
		if(game.getPlayer1() + game.getPlayer2()==18){
			return true;
		}
		return false;
	}
	
	private void endOfGame(){
		if(game.getPlayer1()> game.getPlayer2()){
			lblPlayerName.setText("Croc won!!");
			image.setUrl(game.getImage(PLAYERONE));
			
		}else if(game.getPlayer1()< game.getPlayer2()){
			lblPlayerName.setText("Tiger won!!");
			image.setUrl(game.getImage(PLAYERTWO));
		}else{
			lblPlayerName.setText("The game was drawn.");
			image.setUrl("images/pickme.png");
		}
		gameOver=true;
		btnreset.setText("Play Again?");
		//btnreset.setVisible(true);
		t.schedule(DELAY);
		
	}
	
	private void resetBoard(){
		if(game.getData(1)!=PLAYERONE && game.getData(1)!=PLAYERTWO){
			image1.setUrl("images/pickme.png");
			image1.setStyleName("notPicked");
		}else{
			image1.setUrl(getImage(game.cardPicked(1)));
			image1.setStyleName("pickedPic");
		}
		if(game.getData(2)!=PLAYERONE && game.getData(2)!=PLAYERTWO){
			image2.setUrl("images/pickme.png");
			image2.setStyleName("notPicked");
		}else{
			image2.setUrl(getImage(game.cardPicked(2)));
			image2.setStyleName("pickedPic");
		}
		if(game.getData(3)!=PLAYERONE && game.getData(3)!=PLAYERTWO){
			image3.setUrl("images/pickme.png");
			image3.setStyleName("notPicked");
		}else{
			image3.setUrl(getImage(game.cardPicked(3)));
			image3.setStyleName("pickedPic");
		}
		if(game.getData(4)!=PLAYERONE && game.getData(4)!=PLAYERTWO){
			image4.setUrl("images/pickme.png");
			image4.setStyleName("notPicked");
		}else{
			image4.setUrl(getImage(game.cardPicked(4)));
			image4.setStyleName("pickedPic");
		}
		if(game.getData(5)!=PLAYERONE && game.getData(5)!=PLAYERTWO){
			image5.setUrl("images/pickme.png");
			image5.setStyleName("notPicked");
		}else{
			image5.setUrl(getImage(game.cardPicked(5)));
			image5.setStyleName("pickedPic");
		}
		if(game.getData(6)!=PLAYERONE && game.getData(6)!=PLAYERTWO){
			image6.setUrl("images/pickme.png");
			image6.setStyleName("notPicked");
		}else{
			image6.setUrl(getImage(game.cardPicked(6)));
			image6.setStyleName("pickedPic");
		}
		if(game.getData(7)!=PLAYERONE && game.getData(7)!=PLAYERTWO){
			image7.setUrl("images/pickme.png");
			image7.setStyleName("notPicked");
		}else{
			image7.setUrl(getImage(game.cardPicked(7)));
			image7.setStyleName("pickedPic");
		}
		if(game.getData(8)!=PLAYERONE && game.getData(8)!=PLAYERTWO){
			image8.setUrl("images/pickme.png");
			image8.setStyleName("notPicked");
		}else{
			image8.setUrl(getImage(game.cardPicked(8)));
			image8.setStyleName("pickedPic");
		}
		if(game.getData(9)!=PLAYERONE && game.getData(9)!=PLAYERTWO){
			image9.setUrl("images/pickme.png");
			image9.setStyleName("notPicked");
		}else{
			image9.setUrl(getImage(game.cardPicked(9)));
			image9.setStyleName("pickedPic");
		}
		if(game.getData(10)!=PLAYERONE && game.getData(10)!=PLAYERTWO){
			image10.setUrl("images/pickme.png");
			image10.setStyleName("notPicked");
		}else{
			image10.setUrl(getImage(game.cardPicked(10)));
			image10.setStyleName("pickedPic");
		}
		if(game.getData(11)!=PLAYERONE && game.getData(11)!=PLAYERTWO){
			image11.setUrl("images/pickme.png");
			image11.setStyleName("notPicked");
		}else{
			image11.setUrl(getImage(game.cardPicked(11)));
			image11.setStyleName("pickedPic");
		}
		if(game.getData(12)!=PLAYERONE && game.getData(12)!=PLAYERTWO){
			image12.setUrl("images/pickme.png");
			image12.setStyleName("notPicked");
		}else{
			image12.setUrl(getImage(game.cardPicked(12)));
			image12.setStyleName("pickedPic");
		}
		if(game.getData(13)!=PLAYERONE && game.getData(13)!=PLAYERTWO){
			image13.setUrl("images/pickme.png");
			image13.setStyleName("notPicked");
		}else{
			image13.setUrl(getImage(game.cardPicked(13)));
			image13.setStyleName("pickedPic");
		}
		if(game.getData(14)!=PLAYERONE && game.getData(14)!=PLAYERTWO){
			image14.setUrl("images/pickme.png");
			image14.setStyleName("notPicked");
		}else{
			image14.setUrl(getImage(game.cardPicked(14)));
			image14.setStyleName("pickedPic");
		}
		if(game.getData(15)!=PLAYERONE && game.getData(15)!=PLAYERTWO){
			image15.setUrl("images/pickme.png");
			image15.setStyleName("notPicked");
		}else{
			image15.setUrl(getImage(game.cardPicked(15)));
			image15.setStyleName("pickedPic");
		}
		if(game.getData(16)!=PLAYERONE && game.getData(16)!=PLAYERTWO){
			image16.setUrl("images/pickme.png");
			image16.setStyleName("notPicked");
		}else{
			image16.setUrl(getImage(game.cardPicked(16)));
			image16.setStyleName("pickedPic");
		}
		if(game.getData(17)!=PLAYERONE && game.getData(17)!=PLAYERTWO){
			image17.setUrl("images/pickme.png");
			image17.setStyleName("notPicked");
		}else{
			image17.setUrl(getImage(game.cardPicked(17)));
			image17.setStyleName("pickedPic");
		}
		if(game.getData(18)!=PLAYERONE && game.getData(18)!=PLAYERTWO){
			image18.setUrl("images/pickme.png");
			image18.setStyleName("notPicked");
		}else{
			image18.setUrl(getImage(game.cardPicked(18)));
			image18.setStyleName("pickedPic");
		}
		if(game.getData(19)!=PLAYERONE && game.getData(19)!=PLAYERTWO){
			image19.setUrl("images/pickme.png");
			image19.setStyleName("notPicked");
		}else{
			image19.setUrl(getImage(game.cardPicked(19)));
			image19.setStyleName("pickedPic");
		}
		if(game.getData(20)!=PLAYERONE && game.getData(20)!=PLAYERTWO){
			image20.setUrl("images/pickme.png");
			image20.setStyleName("notPicked");
		}else{
			image20.setUrl(getImage(game.cardPicked(20)));
			image20.setStyleName("pickedPic");
		}
		if(game.getData(21)!=PLAYERONE && game.getData(21)!=PLAYERTWO){
			image21.setUrl("images/pickme.png");
			image21.setStyleName("notPicked");
		}else{
			image21.setUrl(getImage(game.cardPicked(21)));
			image21.setStyleName("pickedPic");
		}
		if(game.getData(22)!=PLAYERONE && game.getData(22)!=PLAYERTWO){
			image22.setUrl("images/pickme.png");
			image22.setStyleName("notPicked");
		}else{
			image22.setUrl(getImage(game.cardPicked(22)));
			image22.setStyleName("pickedPic");
		}
		if(game.getData(23)!=PLAYERONE && game.getData(23)!=PLAYERTWO){
			image23.setUrl("images/pickme.png");
			image23.setStyleName("notPicked");
		}else{
			image23.setUrl(getImage(game.cardPicked(23)));
			image23.setStyleName("pickedPic");
		}
		if(game.getData(24)!=PLAYERONE && game.getData(24)!=PLAYERTWO){
			image24.setUrl("images/pickme.png");
			image24.setStyleName("notPicked");
		}else{
			image24.setUrl(getImage(game.cardPicked(24)));
			image24.setStyleName("pickedPic");
		}
		if(game.getData(25)!=PLAYERONE && game.getData(25)!=PLAYERTWO){
			image25.setUrl("images/pickme.png");
			image25.setStyleName("notPicked");
		}else{
			image25.setUrl(getImage(game.cardPicked(25)));
			image25.setStyleName("pickedPic");
		}
		if(game.getData(26)!=PLAYERONE && game.getData(26)!=PLAYERTWO){
			image26.setUrl("images/pickme.png");
			image26.setStyleName("notPicked");
		}else{
			image26.setUrl(getImage(game.cardPicked(26)));
			image26.setStyleName("pickedPic");
		}
		if(game.getData(27)!=PLAYERONE && game.getData(27)!=PLAYERTWO){
			image27.setUrl("images/pickme.png");
			image27.setStyleName("notPicked");
		}else{
			image27.setUrl(getImage(game.cardPicked(27)));
			image27.setStyleName("pickedPic");
		}
		if(game.getData(28)!=PLAYERONE && game.getData(28)!=PLAYERTWO){
			image28.setUrl("images/pickme.png");
			image28.setStyleName("notPicked");
		}else{
			image28.setUrl(getImage(game.cardPicked(28)));
			image28.setStyleName("pickedPic");
		}
		if(game.getData(29)!=PLAYERONE && game.getData(29)!=PLAYERTWO){
			image29.setUrl("images/pickme.png");
			image29.setStyleName("notPicked");
		}else{
			image29.setUrl(getImage(game.cardPicked(29)));
			image29.setStyleName("pickedPic");
		}
		if(game.getData(30)!=PLAYERONE && game.getData(30)!=PLAYERTWO){
			image30.setUrl("images/pickme.png");
			image30.setStyleName("notPicked");
		}else{
			image30.setUrl(getImage(game.cardPicked(1)));
			image30.setStyleName("pickedPic");
		}
		if(game.getData(31)!=PLAYERONE && game.getData(31)!=PLAYERTWO){
			image31.setUrl("images/pickme.png");
			image31.setStyleName("notPicked");
		}else{
			image31.setUrl(getImage(game.cardPicked(31)));
			image31.setStyleName("pickedPic");
		}
		if(game.getData(32)!=PLAYERONE && game.getData(32)!=PLAYERTWO){
			image32.setUrl("images/pickme.png");
			image32.setStyleName("notPicked");
		}else{
			image32.setUrl(getImage(game.cardPicked(32)));
			image32.setStyleName("pickedPic");
		}
		if(game.getData(33)!=PLAYERONE && game.getData(33)!=PLAYERTWO){
			image33.setUrl("images/pickme.png");
			image33.setStyleName("notPicked");
		}else{
			image33.setUrl(getImage(game.cardPicked(33)));
			image33.setStyleName("pickedPic");
		}
		if(game.getData(34)!=PLAYERONE && game.getData(34)!=PLAYERTWO){
			image34.setUrl("images/pickme.png");
			image34.setStyleName("notPicked");
		}else{
			image34.setUrl(getImage(game.cardPicked(1)));
			image34.setStyleName("pickedPic");
		}
		if(game.getData(35)!=PLAYERONE && game.getData(35)!=PLAYERTWO){
			image35.setUrl("images/pickme.png");
			image35.setStyleName("notPicked");
		}else{
			image35.setUrl(getImage(game.cardPicked(35)));
			image35.setStyleName("pickedPic");
		}
		if(game.getData(36)!=PLAYERONE && game.getData(36)!=PLAYERTWO){
			image36.setUrl("images/pickme.png");
			image36.setStyleName("notPicked");
		}else{
			image36.setUrl(getImage(game.cardPicked(36)));
			image36.setStyleName("pickedPic");
		}
	
	}
	
	private boolean checkForMatch(int i){
		if(game.getData(i) == game.getData(game.getPick())){
			return true;
		}else{
			return false;
		}
		
	}
	
	private void showName(){
		//display player name and number of card
		if(game.getPlayer()==19){
			lblPlayerName.setText("Croc: " + game.getPlayer1() + " cards matched.");
			image.setUrl(game.getImage(PLAYERONE));
		} else{
			lblPlayerName.setText("Tiger: " + game.getPlayer2() + " cards matched.");
			image.setUrl(game.getImage(PLAYERTWO));
		}
	}
	
	private String getImage(int i){
		String temp="images/pickme.png";
			if(game.getImage(i)!=null)
				temp = game.getImage(i);
		return temp;
	}
	
	private void displayPic(int i){
		switch (i){
			case 0: image.setUrl(getImage(game.cardPicked(i))); break;
			case 1: image1.setUrl(getImage(game.cardPicked(i))); break;
			case 2: image2.setUrl(getImage(game.cardPicked(i))); break;
			case 3: image3.setUrl(getImage(game.cardPicked(i))); break;
			case 4: image4.setUrl(getImage(game.cardPicked(i))); break;
			case 5: image5.setUrl(getImage(game.cardPicked(i))); break;
			case 6: image6.setUrl(getImage(game.cardPicked(i))); break;
			case 7: image7.setUrl(getImage(game.cardPicked(i))); break;
			case 8: image8.setUrl(getImage(game.cardPicked(i))); break;
			case 9: image9.setUrl(getImage(game.cardPicked(i))); break;
			case 10: image10.setUrl(getImage(game.cardPicked(i))); break;
			case 11: image11.setUrl(getImage(game.cardPicked(i))); break;
			case 12: image12.setUrl(getImage(game.cardPicked(i))); break;
			case 13: image13.setUrl(getImage(game.cardPicked(i))); break;
			case 14: image14.setUrl(getImage(game.cardPicked(i))); break;
			case 15: image15.setUrl(getImage(game.cardPicked(i))); break;
			case 16: image16.setUrl(getImage(game.cardPicked(i))); break;
			case 17: image17.setUrl(getImage(game.cardPicked(i))); break;
			case 18: image18.setUrl(getImage(game.cardPicked(i))); break;
			case 19: image19.setUrl(getImage(game.cardPicked(i))); break;
			case 20: image20.setUrl(getImage(game.cardPicked(i))); break;
			case 21: image21.setUrl(getImage(game.cardPicked(i))); break;
			case 22: image22.setUrl(getImage(game.cardPicked(i))); break;
			case 23: image23.setUrl(getImage(game.cardPicked(i))); break;
			case 24: image24.setUrl(getImage(game.cardPicked(i))); break;
			case 25: image25.setUrl(getImage(game.cardPicked(i))); break;
			case 26: image26.setUrl(getImage(game.cardPicked(i))); break;
			case 27: image27.setUrl(getImage(game.cardPicked(i))); break;
			case 28: image28.setUrl(getImage(game.cardPicked(i))); break;
			case 29: image29.setUrl(getImage(game.cardPicked(i))); break;
			case 30: image30.setUrl(getImage(game.cardPicked(i))); break;
			case 31: image31.setUrl(getImage(game.cardPicked(i))); break;
			case 32: image32.setUrl(getImage(game.cardPicked(i))); break;
			case 33: image33.setUrl(getImage(game.cardPicked(i))); break;
			case 34: image34.setUrl(getImage(game.cardPicked(i))); break;
			case 35: image35.setUrl(getImage(game.cardPicked(i))); break;
			case 36: image36.setUrl(getImage(game.cardPicked(i))); break;	
		}
	}
	
}
